package es.mgil.whoWantsToBeAMillonaire.dialogs;

import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import es.mgil.whoWantsToBeAMillonaire.R;
import es.mgil.whoWantsToBeAMillonaire.activities.Main;
import es.mgil.whoWantsToBeAMillonaire.util.PreferencesKeys;

public class NoUserInfoDialog extends DialogFragment {
	public static final String NO_USER_INFO_DIALOG_ID = "cancel_dialog_id";

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		Main main = (Main) getActivity();
		AlertDialog.Builder builder = new AlertDialog.Builder(main);
		String name = main.preferences.getString(
				PreferencesKeys.PREFERENCES_NAME, "");
		double longitude = main.preferences.getFloat(
				PreferencesKeys.PREFERENCES_LONGITUDE, 0);
		double latitude = main.preferences.getFloat(
				PreferencesKeys.PREFERENCES_LATITUDE, 0);

		// force to be set the name and coordinates to start playing
		if (name == "") {
			builder.setMessage(R.string.main_dialog_no_name);
		} else if (longitude == 0 || latitude == 0) {
			builder.setMessage(R.string.main_dialog_no_location);
		}

		return builder.create();
	}
}